package com.yl.utils;

import com.yl.shengwang.media.RtcTokenBuilder2;
/**
 * 声网鉴权Token方式
 * @author : y
 * @date :  2024/7/2 14:17
 **/
public class RtcTokenBuilder2Sample {
    // 获取环境变量 AGORA_APP_ID 的值。请确保你将该变量设为你在声网控制台获取的 App ID
    static String appId = System.getenv("a32922af017e4a4fad3aa011fb906020");
    // 获取环境变量 AGORA_APP_CERTIFICATE 的值。请确保你将该变量设为你在声网控制台获取的 App 证书
    static String appCertificate = System.getenv("2f152ec4ae9346c6b0bfb733271d6a5a");
    // 将 channelName 替换为需要加入的频道名
    static String channelName = "channelName";
    // 填入你实际的用户 ID
    static int uid = 2082341273;
    // Token 的有效时间，单位秒
    static int tokenExpirationInSeconds = 3600;
    // 所有的权限的有效时间，单位秒
    static int privilegeExpirationInSeconds = 3600;

    public static String getSwToken(String cname,String uid){
        RtcTokenBuilder2 token = new RtcTokenBuilder2();

        String result = token.buildTokenWithUid("a32922af017e4a4fad3aa011fb906020",
                "2f152ec4ae9346c6b0bfb733271d6a5a",
                cname,
                 Integer.valueOf(uid),
                RtcTokenBuilder2.Role.ROLE_SUBSCRIBER,
                3600,
                3600);

      return result;
    }







}
